﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;


namespace BaoJiaDanBaoCun
{
    [Description("临时物料名称=名称 ，不允许保存")]
    [HotUpdate]
    public class Class1 : AbstractBillPlugIn
    {
        public override void BeforeSave(Kingdee.BOS.Core.Bill.PlugIn.Args.BeforeSaveEventArgs e)
        {
            base.BeforeSave(e);
            DynamicObjectCollection FEntity = this.View.Model.DataObject["SAL_QUOTATIONENTRY"] as DynamicObjectCollection;

            
            //int Count = this.View.Model.GetEntryRowCount("SAL_QUOTATIONENTRY");
            int Count = this.View.Model.GetEntryRowCount("FQUOTATIONENTRY");

            for (int i = 0; i< Count; i++)
            {
                string FMaterialName = FEntity[i]["MaterialName"].ToString(); //物料名称
                string FMINGCHENG = FEntity[i]["FMINGCHENG"].ToString();  //名称

                //保存的时候,校验,备注,必须填写,弹框提示
                //获取备注的值,当备注等于空的时候
                if (FMINGCHENG == "临时物料" && FMaterialName == FMINGCHENG)
                {

                    //警告
                    //this.View.ShowWarnningMessage
                    //    ("名称=物料名称，且为临时物料,不能保存",
                    //    action: (result) =>

                    //    {
                    //    //关闭页面
                    //    this.View.Close();
                    //    }
                    //    );
                    //return;

                    this.View.ShowErrMessage("名称=物料名称，且为临时物料,不能保存");

                }
            }
            
          
        }

    

    }
}
